package org.raymond.iworks.study.basic.structure.linkedlist;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
public class DoubleLinkedListTest {
    public static void main(String[] args) {
        HeroNode2 node1 = new HeroNode2(1, "宋江", "及时雨");
        HeroNode2 node2 = new HeroNode2(2, "卢俊义", "玉麒麟");
        HeroNode2 node3 = new HeroNode2(3, "吴用", "智多星");
        HeroNode2 node4 = new HeroNode2(4, "林冲", "豹子头");
        HeroNode2 node5 = new HeroNode2(5, "公孙胜", "入云龙");
        HeroNode2 node6 = new HeroNode2(6, "关胜", "大刀");
        HeroNode2 node7 = new HeroNode2(7, "秦明", "霹雳火");
        HeroNode2 node8 = new HeroNode2(8, "呼延灼", "双鞭");

        DoubleLinkedList list1 = new DoubleLinkedList();
        list1.add(node1);
        list1.add(node3);
        list1.add(node5);
        list1.add(node7);

        System.out.println("初始化双向链表list1");
        list1.list();

        // 修改
        HeroNode2 update = new HeroNode2(8, "呼延灼豹", "双鞭2");
        list1.update(update);

        System.out.println("修改后");
        list1.list();

        list1.delete(3);
        System.out.println("删除后");
        list1.list();

        DoubleLinkedList list2 = new DoubleLinkedList();
        list2.addByOrder(node4);
        list2.addByOrder(node8);
        list2.addByOrder(node2);
        list2.addByOrder(node6);
        System.out.println("初始化双向链表list2");
        list2.list();
    }
}
